import { Config } from "../../Config"
import { Big, BigState } from "../core/Big"
import { Player } from "../core/Player"
import Utils from "../GameUtils"
import { 天谕 } from "../evolution/天谕"
import { BaseHandler } from "./BaseHandler"
import GameUtils from "../GameUtils"

export class 天谕Handler extends BaseHandler{

    天谕_明魂搜根(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_天谕_明魂搜根)
        let startPoint = this.gameMgr.map_point.get(data.start)
        let endPoint = this.gameMgr.map_point.get(data.end)
        let big_start = startPoint.big as 天谕
        big_start.actionOnce()
        let big_end = endPoint.big
        if (big_end == null) {
            this.handlerMgr.showToast(player, "明魂失败，这里没有大子")
            return
        }
        big_start.smell(big_end.player)
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"天谕_眨眼","username":player.username}))
    }
    
    天谕_天眼传真(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_天谕_天眼传真)
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big as 天谕
        big_start.look()
        this.gameMgr.sendBroadcast(GameUtils.getObj("play_sound",{"sound":"天谕_眨眼","username":player.username}))
    }
    
    /** 直接从小子行动抄过来 */
    天谕_神兵天降(data:any,player:Player) {
        //行动力消耗
        this.handlerMgr.spendAction(player,Config.COST_天谕_神兵天降)
        //出大
        let startPoint = this.gameMgr.map_point.get(data.start)
        let endPoint = this.gameMgr.map_point.get(data.end)
        let big_start = startPoint.big
        big_start.actionOnce()
        let oldBig = endPoint.big
        if(oldBig != null) {
            this.handlerMgr.showToast(player,"出大失败")
            oldBig.deleteState(BigState.HIDE)
            this.gameMgr.sendBroadcast(Utils.getObj("play_effect",{"effect":"big_die","point_id":endPoint.id,"username":player.username}))
            return
        }
        let big = new Big()
        big.init(this.gameMgr,big_start.player,endPoint,big_start.mother,null)
        this.gameMgr.sendBroadcast(Utils.getObj("born_big",{"big":big.toObj()}))
    }
}